package jobs;

import models.automation.ImageFixer;
import models.automation.ImageFixerObserver;
import play.jobs.Job;

import java.io.IOException;
import java.io.Serializable;

public class ImageDuplicatesResolver extends Job implements Serializable {

    private String dataPath;
    private String webCacheKey;

    public ImageDuplicatesResolver(String appPath, String cacheKey){
        this.dataPath = appPath;
        this.webCacheKey = cacheKey;
    }

    public void doJob() throws IOException {
        ImageFixer imageFixer = new ImageFixer();
        ImageFixerObserver observer = new ImageFixerObserver(webCacheKey);
        imageFixer.addObserver(observer);
        imageFixer.clearMD5();
        imageFixer.fixImages(dataPath);
    }
}
